/**
 * 生成13位不重复编码
 * @returns code
 */
export function encoding() {
  var d = new Date();
  var year = d.getFullYear();
  var month = d.getMonth() + 1;
  var date = d.getDate();
  var day = d.getDay();
  year = (year + "").substring(2);
  if (month <= 9) {
    month = "0" + month;
  } else if (date <= 9) {
    date = "0" + date;
  }
  //获取当日凌晨0:00:00（零时整）
  let startTime = parseInt(new Date(new Date().toLocaleDateString()).getTime());
  //获取当日23:59:59
  let endTime = startTime + (24 * 60 * 60 * 1000 - 1);
  //获取当前时间戳
  let currentTime = parseInt(new Date().getTime());
  let remainTime = parseInt(parseInt(endTime) - parseInt(currentTime));
  let time;
  if (parseInt(currentTime) > parseInt(startTime)) {
    if (remainTime < 10) {
      time = "0000000" + remainTime.toString();
    }
    if (remainTime < 100 && remainTime >= 10) {
      time = "000000" + remainTime.toString();
    }
    if (remainTime < 1000 && remainTime >= 100) {
      time = "00000" + remainTime.toString();
    }
    if (remainTime < 10000 && remainTime >= 1000) {
      time = "0000" + remainTime.toString();
    }
    if (remainTime < 100000 && remainTime >= 10000) {
      time = "000" + remainTime.toString();
    }
    if (remainTime < 1000000 && remainTime >= 100000) {
      time = "00" + remainTime.toString();
    }
    if (remainTime < 10000000 && remainTime >= 1000000) {
      time = "0" + remainTime.toString();
    }
    if (remainTime >= 10000000) {
      time = remainTime.toString();
    }
    var id = year + month + date + time;
    return id;
  }
}
// 生成随机消息
export function msglist() {
  const oldArr = [
    `g**** took a loan of 50000 on the platform`,
    `g**** took a loan of 50000 on the platform`,
    `g**** took a loan of 55000 on the platform`,
    `g**** took a loan of 55000 on the platform`,
    `g**** took a loan of 60000 on the platform`,
    `g**** took a loan of 60000 on the platform`,
    `g**** took a loan of 65000 on the platform`,
    `g**** took a loan of 65000 on the platform`,
    `g**** took a loan of 70000 on the platform`,
    `g**** took a loan of 70000 on the platform`,
    `g**** took a loan of 75000 on the platform`,
    `g**** took a loan of 75000 on the platform`,
    `a**** took a loan of 80000 on the platform`,
    `a**** took a loan of 80000 on the platform`,
    `a**** took a loan of 85000 on the platform`,
    `a**** took a loan of 85000 on the platform`,
    `a**** took a loan of 90000 on the platform`,
    `a**** took a loan of 90000 on the platform`,
    `a**** took a loan of 95000 on the platform`,
    `a**** took a loan of 95000 on the platform`,
    `a**** took a loan of 100000 on the platform`,
    `a**** took a loan of 100000 on the platform`,
    `d**** took a loan of 1500000 on the platform`,
    `d**** took a loan of 1500000 on the platform`,
    `u**** took a loan of 200000 on the platform`,
    `u**** took a loan of 200000 on the platform`,
    `a**** took a loan of 250000 on the platform`,
    `a**** took a loan of 250000 on the platform`,
    `a**** took a loan of 300000 on the platform`,
    `a**** took a loan of 300000 on the platform`,
    `d**** took a loan of 350000 on the platform`,
    `a**** took a loan of 400000 on the platform`,
    `a**** took a loan of 400000 on the platform`,
    `a**** took a loan of 450000 on the platform`,
    `a**** took a loan of 450000 on the platform`,
    `e**** took a loan of 500000 on the platform`,
    `e**** took a loan of 500000 on the platform`,
    `a**** took a loan of 550000 on the platform`,
    `a**** took a loan of 550000 on the platform`,
    `w**** took a loan of 600000 on the platform`,
    `w**** took a loan of 600000 on the platform`,
    `a**** took a loan of 650000 on the platform`,
    `a**** took a loan of 650000 on the platform`,
    `a**** took a loan of 700000 on the platform`,
    `a**** took a loan of 700000 on the platform`,
    `a**** took a loan of 750000 on the platform`,
    `a**** took a loan of 750000 on the platform`,
    `a**** took a loan of 800000 on the platform`,
    `a**** took a loan of 800000 on the platform`,
    `a**** took a loan of 850000 on the platform`,
    `a**** took a loan of 850000 on the platform`,
    `a**** took a loan of 900000 on the platform`,
    `a**** took a loan of 900000 on the platform`,
    `a**** took a loan of 950000 on the platform`,
    `a**** took a loan of 950000 on the platform`,
  ];
  const newArr = [];

  let i = 0;
  (() => {
    while (++i < oldArr.length) {
      if (newArr.length != 50) {
        newArr.push(oldArr[Math.floor(Math.random() * 49) + 1]);
      }
    }
  })();
  return newArr;
}
// 全局配置密码
export const getPassword = (key = "password") => {
  const keyData = {
    password: "universa",
  };
  return keyData[key];
};
